import { Provide } from "@midwayjs/decorator";
import { InjectEntityModel } from "@midwayjs/orm";
import { Repository } from "typeorm";
import { UserEntity } from "../entity/UserEntity";

@Provide()
export class UserModel {

    @InjectEntityModel(UserEntity)
    private userRepo:Repository<UserEntity>;

  
    /**
     * 根据用户名和密码获取用户信息
     * @param username {String} 用户名
     * @param password {String} 用户密码
     */
    async getUserByUsernameAndPassword(username, password): Promise<UserEntity> {
        // console.log("getUserByUsernameAndPassword","username",username,"password",password);
        // console.log("this.userRepo",this.userRepo);
        //let users=this.userRepo.find({});
      let user=await this.userRepo.findOne({where:{username:username,password:password}});
    //   console.log("users",users);
      return user;
    }
  }